package com.study.rocketmq.listener;

import com.study.rocketmq.constant.MQTopicConstant;
import com.study.rocketmq.service.impl.RocketMQServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(topic = MQTopicConstant.DEMO_TOPIC
        , consumerGroup = "MQ_TEST_GROUP"
        , selectorExpression = "*" )
public class MQConsumerListener implements RocketMQListener<MessageExt> {

    private static final Logger logger = LoggerFactory.getLogger(MQConsumerListener.class);

    @Override
    public void onMessage(MessageExt message) {
        System.out.println("------>"+message.getTopic() +"--------"+ message.getTags());
        logger.info("received registered message: {}", message);
    }
}
